import React, { PureComponent } from "react";
import ContainerItem from "./ContainerItem";
import { Divider } from "antd";
import "antd/dist/antd.css";
import Req from "../common/Req";

export default class Container extends PureComponent {
  constructor(props) {
    super(props);
    this.state = {
      indexDatas: []
    };
  }
  componentWillMount() {
    this.getIndexDatas();
  }
  render() {
    return (
      <div>
        {this.state.indexDatas.map((item, index) => (
          <ContainerItem key={index} floor={item} />
        ))}
        <Divider />
      </div>
    );
  }

  getIndexDatas() {
    Req("http://localhost:8080/products/index", {}, this.props.history, resp =>
      this.setState({ indexDatas: resp.data })
    );
  }
}
